<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 17-2-22
 * Time: 上午10:41
 */

declare(strict_types=1);

function test(){
    return __FUNCTION__;
}

echo test();


function test2():string {
    return __FUNCTION__;
}

echo test2();


function test3(string $str){
    return $str;
}

echo test3("");




echo PHP_EOL;
function test4(int $i,Closure $sum){
    return $sum($i);
}

$s = function(int $i){
    return $i*$i;
};
echo test4(2,$s).PHP_EOL;



//遍历并处理多维数组，递归处理
function mdarr_parameter($needle, bool $job=false) {
    if (is_array($needle)) {
        foreach($needle as $name => $value) {
            $needle[$name] = mdarr_parameter($value, $job);
        }
    } else {
        // Now you do anything you want...
        if ($job === true) {
//            $needle = stripslashes($needle);
            $needle *= $needle;
        } else {
//            $needle = addslashes($needle);
            $needle *= $needle;
        }
    }
    return $needle;
}


$a = [1,2,3,[4,5,6,[7,8,9,[10,11]]]];
$b = mdarr_parameter($a,true);
print_r($b);






if(!function_exists('wocao')){
    function wocao(){
        echo "wocao";
    }
}
wocao();